﻿using System;
using System.Web.Mvc.Html;
using ControleRepresentante.Logic.Models;

namespace WebSite.ViewModels.IndexViewModels
{
    public static class RepresentanteIndexColumns
    {
        public static Guid Nome = new Guid("8c3f6e71-1cda-476b-9eea-7baed65d746d");
        public static Guid Ativo = new Guid("9add5618-757f-4c66-80b5-774be3a2ccf9");
        public static Guid NumeroUsuarios = new Guid("74d9f36c-a2a2-423e-8797-83bdcdf12a95");
        public static Guid NumeroPedidos = new Guid("74d9f36c-a2a2-423e-8797-83bdcdf12a96");
        public static Guid NumeroClientes = new Guid("74d9f36c-a2a2-423e-8797-83bdcdf12a97");
        public static Guid NumeroVendedores = new Guid("74d9f36c-a2a2-423e-8797-83bdcdf12a98");
        public static Guid NumeroTransportadoras = new Guid("74d9f36c-a2a2-423e-8797-83bdcdf12a99");
        public static Guid NumeroFabricas = new Guid("74d9f36c-a2a2-423e-8797-83bdcdf12a9b");
        public static Guid LastPedido = new Guid("74d9f36c-a2a2-423e-8797-83bdcdf12a9a");
        public static Guid UseJolitex = new Guid("b5ecd0d5-2d9c-4c0b-ab26-4977bd65ddb4");
        public static Guid UseTrivium = new Guid("DB9210B7-C695-44D6-A822-7AE0BC408E32");
    }

    public class RepresentanteIndexViewModel : IndexViewModel<Representante>
    {
        public RepresentanteIndexViewModel()
            : base("Representantes")
        {
        }

        protected override void RegisterColumns(IndexColumnDefinitionsCollectionWrapper<Representante> indexColumnDefinitionsCollectionWrapper)
        {
            indexColumnDefinitionsCollectionWrapper.Register(RepresentanteIndexColumns.Nome, (representante, htmlHelper) => htmlHelper.ActionLink(representante.Nome, "Details", new { id = representante.Id }));
            indexColumnDefinitionsCollectionWrapper.Register(RepresentanteIndexColumns.Ativo, x => x.Ativo);
            indexColumnDefinitionsCollectionWrapper.Register(RepresentanteIndexColumns.NumeroUsuarios, x => x.NumeroDeUsuarios);
            indexColumnDefinitionsCollectionWrapper.Register(RepresentanteIndexColumns.NumeroPedidos, x => x.NumeroDePedidos);
            indexColumnDefinitionsCollectionWrapper.Register(RepresentanteIndexColumns.NumeroClientes, x => x.NumeroDeClientes);
            indexColumnDefinitionsCollectionWrapper.Register(RepresentanteIndexColumns.NumeroVendedores, x => x.NumeroDeVendedores);
            indexColumnDefinitionsCollectionWrapper.Register(RepresentanteIndexColumns.NumeroFabricas, x => x.NumeroDeFabricas);
            indexColumnDefinitionsCollectionWrapper.Register(RepresentanteIndexColumns.NumeroTransportadoras, x => x.NumeroDeTransportadoras);
            indexColumnDefinitionsCollectionWrapper.Register(RepresentanteIndexColumns.LastPedido, x => x.LastPedido.HasValue ? x.LastPedido.Value.ToShortDateString() : "");
            indexColumnDefinitionsCollectionWrapper.Register(RepresentanteIndexColumns.UseJolitex, x => x.UseJolitex);
            indexColumnDefinitionsCollectionWrapper.Register(RepresentanteIndexColumns.UseTrivium, x => x.UseTrivium);
        }
    }
}